package com.fenghuajueli.module_host


import android.os.Bundle
import android.widget.FrameLayout
import androidx.viewpager.widget.ViewPager
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.module_course.fragment.CourseFragment
import com.example.module_word.fragment.PlanFragment
import com.example.module_word.fragment.WordFragment
import com.fenghuajueli.libbasecoreui.utils.MyStatusBarUtils
import com.fenghuajueli.module_home.fragment.HomeFragment
import com.fenghuajueli.module_host.adapter.ViewPagerAdapter
import com.fenghuajueli.module_host.databinding.ActivityMainBinding
import com.fenghuajueli.module_host.fragment.MineFragment
import com.fenghuajueli.module_route.CommonRoute
import com.fenghuajueli.module_user.mine.XmlMineFragment


@Route(path = CommonRoute.COMMON_MAIN)
class MainActivity : BaseMainActivity() {
    private lateinit var binding: ActivityMainBinding


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
        initView()
    }

    private fun initView() {

        //设置顶部导航栏透明
        MyStatusBarUtils.setStatusBarWhite(this, "#00000000")

        //导航相关
        binding.bottomBar.setTitles("首页", "课程", "单词", "我的")
            .setNormalIcons(
                R.mipmap.tab_icon_sy_nor,
                R.mipmap.tab_icon_kc_nor,
                R.mipmap.tab_icon_dc_nor,
                R.mipmap.tab_icon_wd_nor
            )
            .setSelectedIcons(
                R.mipmap.tab_icon_sy_sel,
                R.mipmap.tab_icon_kc_sel,
                R.mipmap.tab_icon_dc_sel,
                R.mipmap.tab_icon_wd_sel
            )
            .generate()

        setupViewPager(binding.viewPager)
        binding.bottomBar.setContainer(binding.viewPager)

    }

    //导航栏跳转
    private fun setupViewPager(viewPager: ViewPager) {
        val adapter = ViewPagerAdapter(supportFragmentManager)
        adapter.addFragment(HomeFragment(), "首页")
        adapter.addFragment(CourseFragment(), "课程")
        adapter.addFragment(PlanFragment(), "单词")
        adapter.addFragment(MineFragment(), "我的")
        viewPager.offscreenPageLimit = 3
        viewPager.adapter = adapter
    }


    //广告预埋
    override fun adBannerView(): FrameLayout {
        return binding.flBanner
    }
}


